{
Function:	_BarsDisplayed

Purpose:	Returns the number of bars visible on the chart.
				
		This function is useful to positioning text and data horizontally on the
		the chart as the user knows how many bars total are displayed.

Notes:		A binary search algorithm would be faster, but this function is called only once
		per chart loading or refresh, so the additional savings from a more efficient
		algorithm would be minimal.

		Examine the method of calling the function below to see how the function
		is called only once per chart load/refresh.

Author:		MarkSanDiego

Version:	05/17/09	initial version


Calling Program usage:

		vars: intrabarpersist NBars(0);

			once (LastBarOnChart) begin
			NBars = _BarsDisplayed;
		end;
}



vars:
	j(0),
	MaxBars(200),				{ maximum visible bars on chart }
	intrabarpersist offset(0),
	LeftDateTime(0),
	DateTime(0);


	once (_LastBarOnChart) begin
		
		LeftDateTime = GetAppInfo(aiLeftDispDateTime); 

		for j = 1 to MaxBars begin
			DateTime = ELDateToDateTime(Date[j]) + ELTimeToDateTime(Time[j]);
			if DateTime >= LeftDateTime then 
				offset = j
			else 
				j = MaxBars;
		end;
	
	end;

	_BarsDisplayed = offset;
		

